1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgColor; 26 27 private import glib.MemorySlice; 28 private import glib.Str; 29 private import glib.c.functions; 30 private import gobject.ObjectG; 31 private import linker.Loader; 32 private import pango.c.functions; 33 public import pango.c.types; 34 35 36 /** 37 * The `PangoColor` structure is used to 38 * represent a color in an uncalibrated RGB color-space. 39 */ 40 public final class PgColor 41 { 42 /** the main Gtk struct */ 43 protected PangoColor* pangoColor; 44 protected bool ownedRef; 45 46 /** Get the main Gtk struct */ 47 public PangoColor* getPgColorStruct(bool transferOwnership = false) 48 { 49 if (transferOwnership) 50 ownedRef = false; 51 return pangoColor; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected void* getStruct() 56 { 57 return cast(void*)pangoColor; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (PangoColor* pangoColor, bool ownedRef = false) 64 { 65 this.pangoColor = pangoColor; 66 this.ownedRef = ownedRef; 67 } 68 69 ~this () 70 { 71 if ( Linker.isLoaded(LIBRARY_PANGO[0]) && ownedRef ) 72 pango_color_free(pangoColor); 73 } 74 75 76 /** 77 * value of red component 78 */ 79 public @property ushort red() 80 { 81 return pangoColor.red; 82 } 83 84 /** Ditto */ 85 public @property void red(ushort value) 86 { 87 pangoColor.red = value; 88 } 89 90 /** 91 * value of green component 92 */ 93 public @property ushort green() 94 { 95 return pangoColor.green; 96 } 97 98 /** Ditto */ 99 public @property void green(ushort value) 100 { 101 pangoColor.green = value; 102 } 103 104 /** 105 * value of blue component 106 */ 107 public @property ushort blue() 108 { 109 return pangoColor.blue; 110 } 111 112 /** Ditto */ 113 public @property void blue(ushort value) 114 { 115 pangoColor.blue = value; 116 } 117 118 /** */ 119 public static GType getType() 120 { 121 return pango_color_get_type(); 122 } 123 124 /** 125 * Creates a copy of @src. 126 * 127 * The copy should be freed with [method@Pango.Color.free]. 128 * Primarily used by language bindings, not that useful 129 * otherwise (since colors can just be copied by assignment 130 * in C). 131 * 132 * Returns: the newly allocated `PangoColor`, 133 * which should be freed with [method@Pango.Color.free] 134 */ 135 public PgColor copy() 136 { 137 auto __p = pango_color_copy(pangoColor); 138 139 if(__p is null) 140 { 141 return null; 142 } 143 144 return ObjectG.getDObject!(PgColor)(cast(PangoColor*) __p, true); 145 } 146 147 /** 148 * Frees a color allocated by [method@Pango.Color.copy]. 149 */ 150 public void free() 151 { 152 pango_color_free(pangoColor); 153 ownedRef = false; 154 } 155 156 /** 157 * Fill in the fields of a color from a string specification. 158 * 159 * The string can either one of a large set of standard names. 160 * (Taken from the CSS Color [specification](https://www.w3.org/TR/css-color-4/#named-colors), 161 * or it can be a value in the form `#rgb`, `#rrggbb`, 162 * `#rrrgggbbb` or `#rrrrggggbbbb`, where `r`, `g` and `b` 163 * are hex digits of the red, green, and blue components 164 * of the color, respectively. (White in the four forms is 165 * `#fff`, `#ffffff`, `#fffffffff` and `#ffffffffffff`.) 166 * 167 * Params: 168 * spec = a string specifying the new color 169 * 170 * Returns: %TRUE if parsing of the specifier succeeded, 171 * otherwise %FALSE 172 */ 173 public bool parse(string spec) 174 { 175 return pango_color_parse(pangoColor, Str.toStringz(spec)) != 0; 176 } 177 178 /** 179 * Fill in the fields of a color from a string specification. 180 * 181 * The string can either one of a large set of standard names. 182 * (Taken from the CSS Color [specification](https://www.w3.org/TR/css-color-4/#named-colors), 183 * or it can be a hexadecimal value in the form `#rgb`, 184 * `#rrggbb`, `#rrrgggbbb` or `#rrrrggggbbbb` where `r`, `g` 185 * and `b` are hex digits of the red, green, and blue components 186 * of the color, respectively. (White in the four forms is 187 * `#fff`, `#ffffff`, `#fffffffff` and `#ffffffffffff`.) 188 * 189 * Additionally, parse strings of the form `#rgba`, `#rrggbbaa`, 190 * `#rrrrggggbbbbaaaa`, if @alpha is not %NULL, and set @alpha 191 * to the value specified by the hex digits for `a`. If no alpha 192 * component is found in @spec, @alpha is set to 0xffff (for a 193 * solid color). 194 * 195 * Params: 196 * alpha = return location for alpha 197 * spec = a string specifying the new color 198 * 199 * Returns: %TRUE if parsing of the specifier succeeded, 200 * otherwise %FALSE 201 * 202 * Since: 1.46 203 */ 204 public bool parseWithAlpha(out ushort alpha, string spec) 205 { 206 return pango_color_parse_with_alpha(pangoColor, &alpha, Str.toStringz(spec)) != 0; 207 } 208 209 /** 210 * Returns a textual specification of @color. 211 * 212 * The string is in the hexadecimal form `#rrrrggggbbbb`, 213 * where `r`, `g` and `b` are hex digits representing the 214 * red, green, and blue components respectively. 215 * 216 * Returns: a newly-allocated text string that must 217 * be freed with g_free(). 218 * 219 * Since: 1.16 220 */ 221 public override string toString() 222 { 223 auto retStr = pango_color_to_string(pangoColor); 224 225 scope(exit) Str.freeString(retStr); 226 return Str.toString(retStr); 227 } 228 }